package com.taldh.design.patterns.singleton;

/**
 * date: 2020/5/24
 *
 * @author 袁小黑
 * @version 1.0.0
 */

public class LazyLoadedInvoryTower {

    private volatile static LazyLoadedInvoryTower invoryTower = null;

    private LazyLoadedInvoryTower() {
        if (invoryTower != null) {
            throw new RuntimeException("already instance");
        } else {
            invoryTower = this;
        }
    }

    public static synchronized LazyLoadedInvoryTower getInstance() {
        if (invoryTower != null) {
            return invoryTower;
        }
        invoryTower = new LazyLoadedInvoryTower();
        return invoryTower;
    }

}
